package lumis.portal.audit;

import java.util.Date;

import lumis.portal.PortalException;
import lumis.portal.manager.ManagerFactory;

/**
 * Data access object for {@link AuditEntry}.
 *
 * @version $Revision: 13093 $ $Date: 2011-05-28 18:40:18 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
class AuditEntryDao
{	
	/**
	 * Removes all audit entries older than the given date.
	 * @param date					the oldest entry date to remain in database.
	 * @throws PortalException		if an error occur deleting the old entries.
	 * @since 6.0.0
	 */
	protected void deleteOldEntries(Date date) throws PortalException
	{
		ManagerFactory
			.getEntityManager()
			.createQuery(
				"delete from AuditEntry where entryDate<=:entryDate")
					.setParameter("entryDate", date)
					.executeUpdate();
	}
}